package com.android.enjoymax;

import java.util.ArrayList;

import android.graphics.Color;
import android.graphics.Color.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

public class EnjoyMaxActivity extends Activity implements OnClickListener {
	public static final String TAG = "EnjoyMax";
	public static final double incrementMoney = 25;
	public static final double incrementTime = 0.5;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //Anirudh editing this file!
        //Arpit is here!!
        
        //manoj is here
        //vishnu is here
        // Now that everyone is here. Let's write code! :D - Arpit 
      
        Drawable drawable = this.getResources().getDrawable(R.drawable.background1);
        
	    //Change background of Activity       
	    getWindow().setBackgroundDrawable(drawable);
	    
        ImageButton ib9 = (ImageButton) findViewById(R.id.imageButton2);
        ib9.setOnClickListener(this);
        ib9.setBackgroundColor(Color.TRANSPARENT);
        
        ImageButton ib1 = (ImageButton) findViewById(R.id.imageButton1);
        ib1.setOnClickListener(this);
        ib1.setBackgroundColor(Color.TRANSPARENT);

        ImageButton ib2 = (ImageButton) findViewById(R.id.ImageButton01);
        ib2.setOnClickListener(this);
        ib2.setBackgroundColor(Color.TRANSPARENT);

        ImageButton ib3 = (ImageButton) findViewById(R.id.ImageButton02);
        ib3.setOnClickListener(this);
        ib3.setBackgroundColor(Color.TRANSPARENT);

        ImageButton ib4 = (ImageButton) findViewById(R.id.ImageButton03);
        ib4.setOnClickListener(this);
        ib4.setBackgroundColor(Color.TRANSPARENT);
        
        EditText money  = (EditText) findViewById(R.id.editText1);
    	money.setText("$25.0");
        EditText time  = (EditText) findViewById(R.id.editText2);
        time.setText("4.0");
    	
    }
    
    @Override
	public void onClick(View v) {
        
    	EditText money  = (EditText) findViewById(R.id.editText1);
    	EditText time  = (EditText) findViewById(R.id.editText2);
    	
		if (v.getId() == R.id.imageButton2) {
			startActivity(new Intent(EnjoyMaxActivity.this, Models.class));
		}
		
		if (v.getId() == R.id.imageButton1) {
			double temp = Double.parseDouble(money.getText().toString().substring(1));
			temp += incrementMoney;
			money.setText("$" + String.valueOf(temp));
			
		}
		
        if (v.getId() == R.id.ImageButton01) {
        	double temp = Double.parseDouble(money.getText().toString().substring(1));
        	
			temp -= incrementMoney;
			if (temp <= 0) return;
			money.setText("$" + String.valueOf(temp));
		}
        
       if (v.getId() == R.id.ImageButton02) {
    		double temp = Double.parseDouble(time.getText().toString());
			temp += incrementTime;
			time.setText(String.valueOf(temp));
		}
 
      if (v.getId() == R.id.ImageButton03) {
    	  double temp = Double.parseDouble(time.getText().toString());
    	  temp -= incrementTime;
      	if (temp < 2) return;
			
			time.setText(String.valueOf(temp));
		
	 }
	}
    
    private void enableMoneyButtons() {}
}

